package com.yuetong.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yuetong.common.annotation.Log;
import com.yuetong.common.core.controller.BaseController;
import com.yuetong.common.core.domain.AjaxResult;
import com.yuetong.common.enums.BusinessType;
import com.yuetong.business.domain.YtElevatorBrands;
import com.yuetong.business.service.IYtElevatorBrandsService;
import com.yuetong.common.utils.poi.ExcelUtil;
import com.yuetong.common.core.page.TableDataInfo;

/**
 * 电梯品牌管理Controller
 * 
 * @author  卓晓君
 * @date 2025-03-08
 */
@RestController
@RequestMapping("/business/brands")
public class YtElevatorBrandsController extends BaseController
{
    @Autowired
    private IYtElevatorBrandsService ytElevatorBrandsService;

    /**
     * 查询电梯品牌管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:brands:list')")
    @GetMapping("/list")
    public TableDataInfo list(YtElevatorBrands ytElevatorBrands)
    {
        startPage();
        List<YtElevatorBrands> list = ytElevatorBrandsService.selectYtElevatorBrandsList(ytElevatorBrands);
        return getDataTable(list);
    }

    /**
     * 导出电梯品牌管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:brands:export')")
    @Log(title = "电梯品牌管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YtElevatorBrands ytElevatorBrands)
    {
        List<YtElevatorBrands> list = ytElevatorBrandsService.selectYtElevatorBrandsList(ytElevatorBrands);
        ExcelUtil<YtElevatorBrands> util = new ExcelUtil<YtElevatorBrands>(YtElevatorBrands.class);
        util.exportExcel(response, list, "电梯品牌管理数据");
    }

    /**
     * 获取电梯品牌管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:brands:query')")
    @GetMapping(value = "/{brandId}")
    public AjaxResult getInfo(@PathVariable("brandId") Long brandId)
    {
        return success(ytElevatorBrandsService.selectYtElevatorBrandsByBrandId(brandId));
    }

    /**
     * 新增电梯品牌管理
     */
    @PreAuthorize("@ss.hasPermi('business:brands:add')")
    @Log(title = "电梯品牌管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YtElevatorBrands ytElevatorBrands)
    {
        return toAjax(ytElevatorBrandsService.insertYtElevatorBrands(ytElevatorBrands));
    }

    /**
     * 修改电梯品牌管理
     */
    @PreAuthorize("@ss.hasPermi('business:brands:edit')")
    @Log(title = "电梯品牌管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YtElevatorBrands ytElevatorBrands)
    {
        return toAjax(ytElevatorBrandsService.updateYtElevatorBrands(ytElevatorBrands));
    }

    /**
     * 删除电梯品牌管理
     */
    @PreAuthorize("@ss.hasPermi('business:brands:remove')")
    @Log(title = "电梯品牌管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{brandIds}")
    public AjaxResult remove(@PathVariable Long[] brandIds)
    {
        return toAjax(ytElevatorBrandsService.deleteYtElevatorBrandsByBrandIds(brandIds));
    }
}
